define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'qjsosuo/index' + location.search,
                    add_url: 'qjsosuo/add',
                    edit_url: 'qjsosuo/edit',
                    del_url: 'qjsosuo/del',
                    multi_url: 'qjsosuo/multi',
                    import_url: 'qjsosuo/import',
                    table: 'qjsosuo',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                search:false,
                showToggle: false,
                showColumns: false,
                searchFormVisible: true,
                showExport: false,
                columns: [
                    [
                        //{checkbox: true},
                        //{field: 'id', title: __('Id'),operate: false},
                        //{field: 'opt_date', title: __('Opt_date'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'caidan', title: __('菜单'), operate: false},
                        {field: 'opt_date', title: __('Opt_date'), operate:false, addclass:'datetimerange', autocomplete:false},
                        //{field: 'yunying', title: __('运营商'), operate: false},

                        {field: 'name', title: __('Name'), operate: 'LIKE'},
                        {field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
                        {field: 'address', title: __('Address'), operate: 'LIKE'},
                        {field: 'price', title: __('金额'), operate: false},
                        {field: 'reason', title: __('原因'), operate: false},
                        {field: 'zhaoshu', title: __('兆数'), operate: false},
                        {field: 'cardid', title: __('身份证号'), operate: false},
                        {field: 'remark', title: __('备注'), operate: false},
                        {field: 'anzhuang_fee', title: __('安装费'), operate: false},
                        {field: 'mao_fee', title: __('光猫'), operate: false},
                        {field: 'phone', title: __('号码'), operate: false},
                        {field: 'account', title: __('账号'), operate: false},
                        {field: 'productid', title: __('产品号'), operate: false},
                        {field: 'ptype', title: __('付款方式'), searchList: {"1":__('现金'),"2":__('微信'),"3":__('支付宝'),"4":__('银行卡'),"5":__('对公户'),"0":__('/')}, formatter: Table.api.formatter.normal, operate: false},

                        //{field: 'shouli_id', title: __('Shouli_id'), operate: false},
                        {field: 'lanzhuang_id', title: __('Lanzhuang_id'), operate: 'LIKE'},
                        {field: 'zhuangji_id', title: __('Zhuangji_id'), operate: 'LIKE'},
                        //{field: 'stype', title: __('Stype'), searchList: {"1":__('Stype 1'),"2":__('Stype 2'),"3":__('Stype 3'),"4":__('Stype 4')}, formatter: Table.api.formatter.normal},
                        //{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        //{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
